<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>服务器状态</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script type="text/javascript">
        function getMemInfo() {
            $.ajax({
                url: "http://127.0.0.1:5000/memory",
                type: "GET",
                dataType: "json",
                success: function (data) {
                    console.log(data);
                    $("#meminfo").html(data.msg);
                },
                error: function (xhr, textStatus, errorThrown) {
                    alert("请求失败");
                }
            });
        }

        function getCpuInfo() {
            $.ajax({
                url: "http://127.0.0.1:5000/cpu",
                type: "GET",
                dataType: "json",
                success: function (data) {
                    console.log(data);
                    $("#cpuinfo").html(data.msg);
                },
                error: function (xhr, textStatus, errorThrown) {
                    alert("请求失败");
                }
            });
        }

        function getDiskInfo() {
            $.ajax({
                url: "http://127.0.0.1:5000/disk",
                type: "GET",
                dataType: "json",
                success: function (data) {
                    console.log(data);
                    $("#diskinfo").html(data.msg);
                },
                error: function (xhr, textStatus, errorThrown) {
                    alert("请求失败");
                }
            });
        }
    </script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <style>
        body {
            font-family: Arial, Helvetica, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }

        h1 {
            color: #333;
            margin-top: 50px;
            text-align: center;
        }

        h2 {
            color: #555;
            margin-top: 30px;
            margin-bottom: 10px;
        }

        .info {
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0px 2px 5px rgba(0,0,0,0.1);
            padding: 20px;
            margin-bottom: 20px;
            text-align: center;
            transition: all 0.2s ease-in-out;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .info:hover {
            transform: translateY(-5px);
            box-shadow: 0px 7px 15px rgba(0,0,0,0.2);
        }

        .btn {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.2s ease-in-out;
        }

        .btn:hover {
            background-color: #3e8e41;
        }

        .icon {
            font-size: 50px;
            margin-bottom: 10px;
        }

        .mem {
            color: #007bff;
        }

        .cpu {
            color: #dc3545;
        }

        .disk {
            color: #ffc107;
        }

        .info-text {
            color: #777;
            font-size: 18px;
            margin-top: 20px;
            display: flex;
            align-items: center;
        }

        .info-text i {
            margin-right: 10px;
        }
    </style>
</head>
<body>
    <h1>服务器状态</h1>
    <div>
        <h2>内存状态</h2>
        <p id="meminfo">点击按钮获取内存状态</p>
        <button onclick="getMemInfo()">获取内存状态</button>
    </div>
    <div>
        <h2>CPU状态</h2>
        <p id="cpuinfo">点击按钮获取CPU状态</p>
        <button onclick="getCpuInfo()">获取CPU状态</button>
    </div>
    <div>
        <h2>硬盘状态</h2>
        <p id="diskinfo">点击按钮获取硬盘状态</p>
        <button onclick="getDiskInfo()">获取硬盘状态</button>
    </div>
</body>
</html>
